def _impl(ctx):
    print("target全称为=", ctx.label)
    new_file = ctx.actions.declare_file(ctx.attr.output_name)
    print(new_file)

    ctx.actions.write(
        output = new_file,
        content = ctx.attr.text,
    )

    return DefaultInfo(
        files = depset([new_file]),
    )

generate_file = rule(
    implementation = _impl,
    attrs = {
        "text": attr.string(mandatory = True),
        "output_name": attr.string(mandatory = True),
    },
)
